package models

import (
	"gorm.io/gorm"
)

/*
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `level_id` int(11) NOT NULL DEFAULT '0' COMMENT '会等级编号',
  `level_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '会员名称',
  `src` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '等级图片',
  `money` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '会员费',
  `duration` int(11) DEFAULT '0' COMMENT '有效时长 秒',
  `app_id` int(11) DEFAULT '0' COMMENT '数据归属',
*/
// Member 对应数据库表 member
type MemberLevel struct {
	gorm.Model
	ID        uint    `gorm:"primaryKey;autoIncrement;comment:主键，自增ID"`
	LevelID   uint    `gorm:"default:0;comment:会等级编号"`
	LevelName string  `gorm:"default:'';comment:会员名称"`
	Src       string  `gorm:"default:'';comment:等级图片"`
	Money     float64 `gorm:"default:0.00;comment:会员费"`
	Duration  int64   `gorm:"default:0;comment:有效时长 秒"`
	AppID     int     `gorm:"default:0;comment:数据归属"`
	CreatedAt int64   `gorm:"autoCreateTime;comment:创建时间戳"` // 修改为 uint64
	UpdatedAt int64   `gorm:"autoUpdateTime;comment:更新时间戳"` // 修改为 uint64
}

type MemberLevelList struct {
	ID        uint    `json:"id"`
	LevelID   uint    `json:"level_id"`
	LevelName string  `json:"level_name"`
	Src       string  `json:"src"`
	Money     float64 `json:"money"`
	Duration  int64   `json:"duration"`
	AppID     int     `json:"app_id"`
	CreatedAt string  `json:"created_at"`
	UpdatedAt string  `json:"updated_at"`
}

type MemberLevelCreate struct {
	LevelID   uint    `json:"level_id"`
	LevelName string  `json:"level_name"`
	Src       string  `json:"src"`
	Money     float64 `json:"money"`
	Duration  int64   `json:"duration"`
	AppID     int     `json:"app_id"`
}

type MemberLevelUpdate struct {
	ID        uint    `json:"id"`
	LevelID   uint    `json:"level_id"`
	LevelName string  `json:"level_name"`
	Src       string  `json:"src"`
	Money     float64 `json:"money"`
	Duration  int64   `json:"duration"`
	AppID     int     `json:"app_id"`
}

// TableName 设置表名为 member
func (MemberLevel) TableName() string {
	return "member_level"
}
